<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ page import="com.scalar.chiptrack.operations.lotcorrection.forms.LotCorrectionForm,
                 com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.commons.Constants" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>


<chiptrack:checkLogon sourcePage="/lotCorrection.do"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>

<script language="javascript">

function loadProducts()
{
    var form = document.lotReworkForm;
	if( form.processType.value == '0' )
    {
        form.action="<%=chipTracContext%>/lotRework.do";
	    form.submit();
        return ;
    }
    else
    {
	    form.action="<%=chipTracContext%>/lotRework.do?action=loadProducts";
	    form.submit();
    }
}

function loadNewProducts()
{
    var form = document.lotReworkForm;
	if( form.newProcessType.value == '0' )
    {
        form.action="<%=chipTracContext%>/lotRework.do?action=loadLot";
	    form.submit();
        return ;
    }
    else
    {
	    form.action="<%=chipTracContext%>/lotRework.do?action=loadNewProducts";
	    form.submit();
    }
}

function loadLocations()
{
    var form = document.lotReworkForm;
	if( form.processStepId.value == '0' )
    {
        form.action="<%=chipTracContext%>/lotRework.do?action=loadProducts";
	    form.submit();
        return ;
    }
    else
    {
	    form.action="<%=chipTracContext%>/lotRework.do?action=loadLocations";
	    form.submit();
    }
}

function loadNewLocations()
{
    var form = document.lotReworkForm;
	if( form.newProcessStepId.value == '0' )
    {
        form.action="<%=chipTracContext%>/lotRework.do?action=loadNewProducts";
	    form.submit();
        return ;
    }
    else
    {
	    form.action="<%=chipTracContext%>/lotRework.do?action=loadNewLocations";
	    form.submit();
    }
}

function loadLotNumbers()
{
    var form = document.lotReworkForm;
	if( form.locationId.value == '0' )
    {
        form.action="<%=chipTracContext%>/lotRework.do?action=loadLocations";
	    form.submit();
        return ;
    }
    else
    {
	    form.action="<%=chipTracContext%>/lotRework.do?action=loadLotNumbers";
	    form.submit();
    }
}

function loadLot()
{
    var form = document.lotReworkForm;

    if( form.lotId.value == '0' )
    {
        form.action="<%=chipTracContext%>/lotRework.do?action=loadLotNumbers";
	    form.submit();
        return ;
    }
    else
    {
	    form.action="<%=chipTracContext%>/lotRework.do?action=loadLot";
	    form.submit();
    }
}

function loadLotDetails()
{
    var form = document.lotReworkForm;

    if( form.newLocationId.value == '0' )
    {
        form.action="<%=chipTracContext%>/lotRework.do?action=loadNewLocations";
	    form.submit();
        return ;
    }
    else
    {
	    form.action="<%=chipTracContext%>/lotRework.do?action=enterNewLot";
	    form.submit();
    }
}

function save()
{
	var form = document.lotReworkForm;
    var pa=document.getElementById("message");
	pa.innerHTML = "";

    if ( checkInteger( form.newQtyIn.value , ' Rework Quantity In ' , 'Y'  ) == false )
	{
		pa.innerHTML = "<li> "+errMsg;
		form.newQtyIn.focus();
		return;
	}

	if ( parseInt ( form.newQtyIn.value ) == 0 )
	{
		pa.innerHTML = "<li>Zero value is not permitted for Rework Quantity In, Please enter greater than Zero";
		form.newQtyIn.focus();
		return;
	}
    if ( parseInt (form.newQtyIn.value) > parseInt ( form.qtyIn.value) )
    {
        pa.innerHTML = "<li>Rework Quantity In - Should not be greater than Quantity In";
		form.newQtyIn.focus();
		return;
    }
    if(form.newDateIn.value == '')
    {
        pa.innerHTML = "<li> Please Enter Rework Date In";
        form.newDateIn.focus();
		return;
    }

    if( form.newDateIn.value != '')
    {
         if ( chkDate ( form.newDateIn.value , 'Rework Date In ' , 'Y' ) == false ){
              pa.innerHTML = errMsg;
              form.newDateIn.focus();
              return;
        }
    }
    if ( CompareDate( form.dateIn.value,form.newDateIn.value ) == false )
    {
        pa.innerHTML = "<li>Reowrk Date In - can not be before Date In"
        form.newDateIn.focus();
        return;
    }

    if( ( typeof form.prevDateIn != 'undefined' ) &&  form.prevDateIn.value != '')
    {
        if ( CompareDate( form.prevDateIn.value,form.newDateIn.value ) == false )
        {
            pa.innerHTML = "<li>Rework Date In - can not be less than Existing Date In"
            form.newDateIn.focus();
            return;
        }
    }

    form.action="<%=chipTracContext%>/lotRework.do?action=saveLot";
    form.submit();
}

function openCalendar(dateValue)
{
	dateElement = dateValue;
	newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
	newWindow.moveTo(550,180);
	newWindow.focus();
}

function assignDate(passedValue)
{
	dateElement.value=passedValue;
	window.focus();
}

function showLotInformation()
{
    var processStepId = document.lotReworkForm.newProcessStepId.value;
    var lotId         = document.lotReworkForm.lotId.value;
    var locationId    = document.lotReworkForm.newLocationId.value;
    newWindow = window.open ('<%=chipTracContext%>/lotRework.do?action=allLotInfo&LotId='+lotId+'&ProcessStepId='+processStepId+'&LocationId='+locationId,'optionsPopup1','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=500,height=450,resizable=no');
    newWindow.focus();
}

</script>
<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
<!-- Top Header Start-->

<%@ include file="/jsp/includes/header.jsp" %>

<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<!--TBODY-->
<TR>
<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%@ include file="/jsp/operations/dataentryMenu.jsp" %>

<!-- end of the side navigations -->

<TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8/></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2/></TD>
<TD valign="top" width="100%">
<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0/>
<BR>

<!-- from here your body starts -->
<html:form name="lotReworkForm"  type="com.scalar.chiptrack.operations.lotcorrection.forms.LotReworkForm" action="/lotRework">
<table border="0" width="90%" align=center>
    <tr><td colspan=5 class="NArialW" align="center">Lot Rework</td></tr>
    <tr><td colspan=5>&nbsp;</td></tr>
    <tr><td colspan=5 class='NArialL'><strong><FONT id="message" styleClass="NArialL" color='FF0000'></FONT></td></tr>
    <tr>
        <td colspan=5>&nbsp;
            <chiptrack:info styleClass="NArialL" />
            <chiptrack:errors styleClass="NArialL" />
            <chiptrack:messages type="info" styleClass="NArialL" />
        </td>
    </tr>
    <logic:equal name="showMessage" value="TRUE">
        <tr>
            <td colspan=5 align='left'>
                <font class='NArialS' color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b></font>
            </td>
        </tr>
    </logic:equal>
    <tr><td colspan=5>&nbsp;</td></tr>
    <tr>
        <td>
            <table border="0" width="100%">
                <tr>
					<td width="20%"><font class="NArialL">Select Process Type:</font></td>
                    <td width="25%">
                        <p>
                        <font class="NArialL">
                        <html:select property="processType"  styleClass="txfield" onchange="javascript:loadProducts();" >
                            <html:option value="0">Select Process Type</html:option>
                            <html:options collection="processList" property="value" labelProperty="label"/>
                        </html:select>
                        </font>
                        </p>
                    </td>
                    <logic:present name="productList" >
                        <td width="20%"><font class="NArialL">Select Product Name:</font></td>
                        <td width="20%" align=left>
                            <font class="NArialL">
	                            <html:select property="processStepId"  styleClass="txfield" onchange="loadLocations()"  >
	                                <html:option value="0">Select Part Number</html:option>
                                    <html:options collection="productList" property="value" labelProperty="label"/>
                                </html:select>
                            </font>
                        </td>
                    </logic:present>
                    <logic:notPresent name="productList">
                        <td width="40%" colspan="2"/>
                    </logic:notPresent>
                </tr>

                <tr>
                    <logic:present name="locationList" >
                        <td width="20%"><font class="NArialL">Select Location:</font></td>
                        <td width="25%">
                            <p>
                            <font class="NArialL">
                            <html:select property="locationId"  styleClass="txfield" onchange="loadLotNumbers()"  >
                                <html:option value="0">Select Location</html:option>
                                <html:options collection="locationList" property="value" labelProperty="label"/>
                            </html:select>
                            </font>
                            </p>
                        </td>
                    </logic:present>
                    <logic:notPresent name="locationList">
                        <td width="40%" colspan="2"/>
                    </logic:notPresent>
                    <logic:present name="lotNumberList" >
                        <td width="20%"><font class="NArialL">Select Lot:</font></td>
                        <td width="25%">
                            <p>
                            <font class="NArialL">
                            <html:select property="lotId"  styleClass="txfield" onchange="loadLot()"  >
                                <html:option value="0">Select Lot</html:option>
                                <html:options collection="lotNumberList" property="value" labelProperty="label"/>
                            </html:select>
                            </font>
                            </p>
                        </td>
                    </logic:present>
                    <logic:notPresent name="lotNumberList">
                        <td width="40%" colspan="2"/>
                    </logic:notPresent>
                </tr>
				<logic:notEmpty  name="lotReworkForm" property="dateIn">
				<tr>
						 <td width="20%"><font class="NArialL">Qty In:</font></td>
						 <td width="25%"><p><font class="NArialL">	
							<html:text name="lotReworkForm" property="qtyIn" styleClass="valuetxfield" size="20" disabled="true"/>
						 </font></p></td>
						 <td width="20%"><font class="NArialL">Date In:</font></td>
						 <td width="25%"><p><font class="NArialL">	
							<html:text name="lotReworkForm" property="dateIn" styleClass="valuetxfield" size="20" disabled="true" />
						 </font></p></td>
				</tr>	
				<tr><td colspan="5">&nbsp;&nbsp;</td></tr>
				<logic:present name="newProcessList" >
				<tr><td colspan="5" Align="left" ><font class="NArialL">Transfer Lot to :</font></td></tr>
				<tr><td colspan="5">&nbsp;&nbsp;</td></tr>
				<td width="20%"><font class="NArialL">Select Rework Process Type:</font></td>
				<td width="25%"><p><font class="NArialL">
					<html:select property="newProcessType" styleClass="txfield" onchange="javascript:loadNewProducts();" >
						<html:option value="0">Select Process Type</html:option>
						<html:options collection="newProcessList" property="value" labelProperty="label"/>
					</html:select>
				</td>
                </logic:present>
				<logic:notPresent name="newProcessList">
					<td width="40%" colspan="2"/>
				</logic:notPresent>

                <logic:present name="newProductList" >
                <td width="20%"><font class="NArialL">Select Rework Product Name:</font></td>
				<td width="20%" align=left><font class="NArialL">
					<html:select property="newProcessStepId"  styleClass="txfield" onchange="loadNewLocations()"  >
						<html:option value="0">Select Part Number</html:option>
						<html:options collection="newProductList" property="value" labelProperty="label"/>
					</html:select>
				 </font></td>
				</logic:present>
				<logic:notPresent name="newProductList">
					<td width="40%" colspan="2"/>
				</logic:notPresent>

                <tr>
                    <logic:present name="newLocationList" >
                        <td width="20%"><font class="NArialL">Select Rework Location:</font></td>
                        <td width="25%">
                            <p>
                            <font class="NArialL">
                            <html:select property="newLocationId"  styleClass="txfield" onchange="loadLotDetails()"  >
                                <html:option value="0">Select Location</html:option>
                                <html:options collection="newLocationList" property="value" labelProperty="label"/>
                            </html:select>
                            </font>
                            </p>
                        </td>
                    </logic:present>
                    <logic:notPresent name="newLocationList">
                        <td width="40%" colspan="2"/>&nbsp;</td>
                    </logic:notPresent>
                    <td width="40%" colspan="2"/>&nbsp;</td>
                </tr>
				</logic:notEmpty>
				<logic:equal name="showNewLotInfo" value="true">
				<tr>
					 <td width="20%"><font class="NArialL">Rework Qty In:</font></td>
					 <td width="25%"><p><font class="NArialL">	
						<html:text name="lotReworkForm" property="newQtyIn" styleClass="valuetxfield" size="20"/>
					 </font></p></td>
					 <td width="20%"><font class="NArialL">Rework Date In:</font></td>
					 <td width="25%"><p><font class="NArialL">	
						<html:text name="lotReworkForm" property="newDateIn" styleClass="valuetxfield" size="20" maxlength="10"/>
						<a href="javascript:openCalendar(document.lotReworkForm.newDateIn)">
		                <img onMouseOver="window.status='Click here to select date';return true"  onMouseOut="window.status='';return true" border="0" align='center'
		                src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
					 </font></p></td>
				</tr>
				<html:hidden name="lotReworkForm" property="prevLotExists"/>
				<logic:equal name="lotReworkForm" property="prevLotExists" value="true">
				<tr><td colspan="5"><font class="NArialL">&nbsp;</font></td></tr>
				<tr><td colspan="5"><font class="NArialL">Existing Lot Information at the Location:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>
                        <font class="NArialL"><a styleClass="leftsection" href="javascript:showLotInformation()"
                        onmouseover="window.status='Click to show All Lot info';return true" onmouseout="window.status='';return true">Click here</a>
                        &nbsp;to view Lot History</font></td>
                </tr>
				<tr><td colspan="5"><font class="NArialL">&nbsp;</font></td></tr>
				<tr>
					 <td width="20%"><font class="NArialL">Existing Qty In:</font></td>
					 <td width="25%"><p><font class="NArialL">
						<html:text name="lotReworkForm" property="prevQtyIn" styleClass="valuetxfield" size="20" disabled="true"/>
					 </font></p></td>
					 <td width="20%"><font class="NArialL">Existing Date In:</font></td>
					 <td width="25%"><p><font class="NArialL">	
						<html:text name="lotReworkForm" property="prevDateIn" styleClass="valuetxfield" size="20" disabled="true"/>
					 </font></p></td>
				</tr>
                <tr>
                     <td colspan ="2">&nbsp;</td>
					 <td colspan ="2">&nbsp;</td>
                </tr>
				<tr>
					 <td colspan ="2" width="40%"><font class="NArialL">Add/Overide/Ignore Inventory:</font></td>
					 <td colspan ="2" align="left" width="50%">
                            <html:select property="existingInventory" styleClass="txfield" >
                                <html:option value="1">Add to existing</html:option>
                                <html:option value="2">Over Ride</html:option>
								<html:option value="3">Ignore</html:option>
                            </html:select>
					 </td>
				</tr>

				</logic:equal>
				<tr><td colspan=5>&nbsp;&nbsp;</td></tr>
				<tr>
                    <td align=center colspan=4>
                        <chiptrack:restrictedLink functionality='<%=Functionality.LOT_CORRECTION%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:save();' onmouseover="window.status='Click to Save Lot Data';return true" onmouseout="window.status='';return true">
                            <img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" title='Click here to Save Lot Data'/>
                        </chiptrack:restrictedLink>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="<%=chipTracContext%>/lotRework.do"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" width="53" height="17" onmouseover="window.status='Click to Cancel Changes';return true" onmouseout="window.status='';return true" title="Click here to Cancel Changes"></a>
                    </td>
                </tr>
				</logic:equal>
           </table>
</td></tr>
<tr><td>
</td></tr>
</table>
</html:form>
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>
